package com.itheima05;

import java.io.IOException;
import java.net.*;
import java.util.Scanner;

public class UDP01 {
    public static void main(String[] args) throws IOException {

        Scanner sc = new Scanner(System.in);
        System.out.println("请输入您的数据:");
        DatagramSocket datagramSocket = new DatagramSocket();
        InetAddress byName = InetAddress.getByName("127.0.0.1");

        while (true) {

            String s = sc.nextLine();
            if (s.equals("over")) {
                break;
            }

            byte[] bytes = s.getBytes();
            DatagramPacket datagramPacket = new DatagramPacket(bytes, bytes.length, byName, 10000);

            datagramSocket.send(datagramPacket);

        }
        datagramSocket.close();
    }
}
